package com.linjuke.beginsum.web.modules.action;

import com.linjuke.beginsum.biz.ao.UserAO;
import com.linjuke.beginsum.web.common.BaseAction;
import com.linjuke.water.common.domains.BaseUserDO;
import com.zjuh.splist.core.annotation.DefaultTarget;
import com.zjuh.splist.web.RunData;
import com.zjuh.splist.web.TemplateContext;
import com.zjuh.sweet.result.Result;

public class LoginAction extends BaseAction {

	private UserAO userAO;
	
	@DefaultTarget("json/loginSuccess")
	public void doLogin(RunData rundata, TemplateContext templateContext) {
		String ssid = rundata.getQueryString().getString("ssid");
		BaseUserDO userDO = new BaseUserDO();
		userDO.setSsid(ssid);
		Result result = userAO.handleLogin(userDO);
		if (!result.isSuccess()) {
			this.handleErrorJson(result, rundata, templateContext);
		} else {
			this.result2Context(result, templateContext);
		}
	}

	public void setUserAO(UserAO userAO) {
		this.userAO = userAO;
	}
	
}
